package model.quiz
{
	public class MathQuizModel
	{
		public var range:Number = 10;
		
		public var operateType:int = 1;
		
		public var numSize:int = 2;
		
		public var questionList:Vector.<MathQuestionVo>;
		
		public var questionNum:int = 10;
		
		//public var myanswers:Vector
		public var rightnum:int = 0;
		
		public var score:int = 0;
		private static var _instance:MathQuizModel;
		public static function get instance():MathQuizModel
		{
			if(_instance == null)
				_instance = new MathQuizModel();
			return _instance;
		}
		
		
		public function MathQuizModel()
		{
			
		}
		
		public function randomQuestion():void
		{
			questionList = new Vector.<MathQuestionVo>();
			for(var i:int=0;i < questionNum;i++)
			{
				var qvo:MathQuestionVo = new MathQuestionVo(range,operateType,numSize);
				questionList.push(qvo);
			}
		}
		
		public function calculateScore():void
		{
			 rightnum = 0;
			
			for(var i:int=0;i < questionNum;i++)
			{
				if(questionList[i].answer == questionList[i].myanswer)
					rightnum++;
				
			}
			
			score = Math.floor((rightnum/questionList.length)*100);
		}
	}
}